package com.lzb.permanentcalendar.dialog;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;

import androidx.annotation.NonNull;

import com.aigestudio.wheelpicker.WheelPicker;
import com.lzb.permanentcalendar.R;
import com.lzb.permanentcalendar.basic.dialog.BaseSmartDialog;
import com.lzb.permanentcalendar.databinding.DialogSelDateBinding;
import com.lzb.permanentcalendar.databinding.DialogSelRemindBinding;
import com.nlf.calendar.LunarMonth;
import com.nlf.calendar.LunarYear;
import com.nlf.calendar.Solar;
import com.nlf.calendar.util.SolarUtil;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class SelRemindDialog extends BaseSmartDialog<DialogSelRemindBinding> implements View.OnClickListener {

    private List<String> datas = new ArrayList<>();

    public SelRemindDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected int getGravity() {
        return Gravity.BOTTOM;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_sel_remind;
    }

    @Override
    protected void initView(View view) {
        mDataBinding.tvCancel.setOnClickListener(this);
        mDataBinding.tvConfirm.setOnClickListener(this);

        mDataBinding.wheelPicker1.setItemTextSize(50);
        mDataBinding.wheelPicker1.setItemTextColor(Color.parseColor("#80202739"));
        mDataBinding.wheelPicker1.setSelectedItemTextColor(Color.parseColor("#202739"));
        mDataBinding.wheelPicker1.setVisibleItemCount(5);
        mDataBinding.wheelPicker1.setItemSpace(80);
        setData();
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.tvCancel) {
            dismiss();
        } else if (id == R.id.tvConfirm) {
            dismiss();
            if (listener != null) {
                int selectedItemPosition = mDataBinding.wheelPicker1.getCurrentItemPosition();
                String name = (String) mDataBinding.wheelPicker1.getData().get(selectedItemPosition);
                listener.clickConfirm(name);
            }
        }
    }

    private void setData() {
        datas.clear();

        datas.add(getContext().getString(R.string.remind_type1));
        datas.add(getContext().getString(R.string.remind_type2));
        datas.add(getContext().getString(R.string.remind_type3));
        datas.add(getContext().getString(R.string.remind_type4));
        datas.add(getContext().getString(R.string.remind_type5));
        mDataBinding.wheelPicker1.setData(datas);
    }

    private Ilistener listener;

    public void setListener(Ilistener listener) {
        this.listener = listener;
    }

    public interface Ilistener {
        void clickConfirm(String name);
    }
}
